/*
 * Copyright (C) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LOTTIEPRO_CONTROLLER_BRIDGE_H
#define LOTTIEPRO_CONTROLLER_BRIDGE_H

#include "common/common.h"
#include "controller/lottie_handler.h"
#include "dataManager/lottie_config_data.h"
#include "napi/native_api.h"
#include <arkui/native_node_napi.h>
#include <string>

namespace LottiePro {

enum class LottieBaseAction {
    PLAY,
    PAUSE,
    STOP,
    TOGGLE_PAUSE
};

class LottieControllerBridge {
public:
    LottieControllerBridge() = default;

    static napi_value HandleLottieBaseAction(napi_env env, napi_callback_info info, LottieBaseAction action);

    static napi_value SetId(napi_env env, napi_callback_info info);
    static napi_value GetId(napi_env env, napi_callback_info info);
    static napi_value GetFirstFrame(napi_env env, napi_callback_info info);
    static napi_value GetLoaded(napi_env env, napi_callback_info info);
    static napi_value SetCurrentFrame(napi_env env, napi_callback_info info);
    static napi_value GetCurrentFrame(napi_env env, napi_callback_info info);
    static napi_value SetCurrentRawFrame(napi_env env, napi_callback_info info);
    static napi_value GetCurrentRawFrame(napi_env env, napi_callback_info info);
    static napi_value GetTotalFrames(napi_env env, napi_callback_info info);
    static napi_value GetDataFrameRate(napi_env env, napi_callback_info info);
    static napi_value GetFrameMult(napi_env env, napi_callback_info info);
    static napi_value GetPlayCount(napi_env env, napi_callback_info info);
    static napi_value GetIsPaused(napi_env env, napi_callback_info info);
    static napi_value GetAutoPlay(napi_env env, napi_callback_info info);
    static napi_value GetLoop(napi_env env, napi_callback_info info);
    static napi_value GetTimeCompleted(napi_env env, napi_callback_info info);
    static napi_value GetSegmentPos(napi_env env, napi_callback_info info);
    static napi_value GetIsSubframeEnabled(napi_env env, napi_callback_info info);
    static napi_value SetPlaySpeed(napi_env env, napi_callback_info info);
    static napi_value GetPlaySpeed(napi_env env, napi_callback_info info);
    static napi_value SetPlayDirection(napi_env env, napi_callback_info info);
    static napi_value GetPlayDirection(napi_env env, napi_callback_info info);
    static napi_value GetSegments(napi_env env, napi_callback_info info);

    static napi_value Play(napi_env env, napi_callback_info info);
    static napi_value Pause(napi_env env, napi_callback_info info);
    static napi_value Stop(napi_env env, napi_callback_info info);
    static napi_value TogglePause(napi_env env, napi_callback_info info);

    static napi_value Destroy(napi_env env, napi_callback_info info);
    static napi_value GoToAndStop(napi_env env, napi_callback_info info);
    static napi_value GoToAndPlay(napi_env env, napi_callback_info info);
    static napi_value SetSegment(napi_env env, napi_callback_info info);
    static napi_value ResetSegments(napi_env env, napi_callback_info info);
    static napi_value SetSpeed(napi_env env, napi_callback_info info);
    static napi_value SetDirection(napi_env env, napi_callback_info info);
    static napi_value PlaySegments(napi_env env, napi_callback_info info);
    static napi_value SetSubframe(napi_env env, napi_callback_info info);
    static napi_value GetDuration(napi_env env, napi_callback_info info);
    static napi_value TriggerEvent(napi_env env, napi_callback_info info);
    static napi_value AddEventListener(napi_env env, napi_callback_info info);
    static napi_value RemoveEventListener(napi_env env, napi_callback_info info);
    static napi_value ChangeColor(napi_env env, napi_callback_info info);
    static napi_value ReLoad(napi_env env, napi_callback_info info);
    static napi_value SetContentMode(napi_env env, napi_callback_info info);
    static napi_value SetFrameRate(napi_env env, napi_callback_info info);
    static napi_value Construct(napi_env env, napi_callback_info info);
    static napi_value Exports(napi_env env, napi_value &exports);

private:
    std::string lottieId_;

public:
    void SetLottieId(std::string lottieId);
};
} // namespace LottiePro
#endif // LOTTIEPRO_CONTROLLER_BRIDGE_H
